<%-- 
    Document   : BudgetPlanMainPage
    Created on : Nov 23, 2012, 12:10:09 AM
    Author     : Admin
--%>


<%@page import="edu.fpt.common.Plans"%>
<%@page import="edu.fpt.calendar.BeginEnd"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.DateFormat"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.Collection"%>
<%@page import="Connection.PlanEntity"%>
<%@page import="Connection.PlanDAL"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="pf"
          uri="/WEB-INF/tlds/pf_tag_lib.tld"%>
<!DOCTYPE html>
<html>
    <head>
        <script src="../Theme/calendar.js" type="text/javascript"></script>
        <script src="../Theme/NumberAllow.js" type="text/javascript"></script>
        <link rel="stylesheet" type="text/css" href="../Theme/calendar.css">
        <link rel="stylesheet" type="text/css" href="../Theme/style.css">
        <script src="../Theme/jquery-1.7.2.js" type="text/javascript">
        </script>
        <script src="../Theme/Script.js" type="text/javascript">
        </script>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body onload="init()">

        <script type="text/javascript">
            function init() {
                calendar.set("date")
                calendar.set("dateHappen")
                calendar.set("dateBegin")
                calendar.set("dateEnd")
                calendar.set("PlanBegin")
                calendar.set("PlanEnd")
            };
        </script>


        <!--  create a edit form      -->
        <%
            boolean isEdit = false;
            Plans edit = null;
            if (request.getParameter("EditID") != null) {
                String id = request.getParameter("EditID");
                edit = PlanDAL.searchBudget(id);
                session.setAttribute("id", id);
                isEdit = true;
            }
        %>

        <div class="logo_holder" ><pf:logo_tag/></div>
    <center>
        <div class="container">

            <div class="container_left"><%@include file="/leftpannel.jsp" %></div>
            <div class="container_middle">
                <div class="plan_head">
                    <% if (!isEdit) {%>
                    <center><div class="add"><table><tr><td><div class="add-butt">+</div></td><td>ADD NEW PLAN</td></tr></table></div></center>
                    <center>
                        <div class="add2">
                            <form action="CreateState.jsp" method="POST">
                                <table>
                                    <tr>
                                        <td><span class="lab">Name </span><input type="text" style="width: 200px" name="name"></td>
                                        <td>Day: <input type='text' name='date' id='date' required /></td>
                                        <td><span class="lab"> Type </span><select name="type">
                                                <option>Weekly</option>
                                                <option>Monthly</option>
                                                <option>Unexpected</option>
                                            </select></td>
                                        <td><span class="lab"> Amount: </span><input type="text" style="width: 60px" name="amount"></td>
                                        <td><span class="lab"> Kind </span><select name="kind">
                                                <option>Income</option>
                                                <option>Outcome</option>
                                            </select></td>
                                        <td><input type="submit" name="button-add" class="butt_edit" value="ADD"></td>
                                        <td class="bud-del" id="add_cancel"><img height="10px" width="10px" src="../Image/x.png"></td>
                                    </tr>
                                </table>
                            </form>
                        </div>
                    </center>
                    <% } else {%>
                    <center>
                        <div class="add2_edit">
                            <form action="Edit.jsp" method="POST">
                                <table>
                                    <tr>
                                        <td><span class="lab"> Name </span>
                                            <input type="text" name="edit_name" value="<%=edit.getName()%>" required/>
                                        </td>
                                        <td><span class="lab">  Day: </span>
                                            <input type="text" name="date" id="date" />
                                        </td>
                                        <td><span class="lab"> Amount </span>
                                            <input type="text" name="edit_amount" style="width: 60px" onKeyPress="return checkIt(event)" value="<%=edit.getAmount()%>" required/>
                                        </td>
                                        <td><span class="lab">Kind </span><select name="edit_kind" >
                                                <option>Income</option>
                                                <option>Outcome</option>
                                            </select>
                                        </td>
                                        <td><input type="submit" class="butt_edit" value="Save"/> </td>
                                        <td class="bud-del2" id="add_cancel"><a href="BudgetPlanMainPage.jsp"><img height="10px" width="10px" src="../Image/x.png"></a></td>
                                    </tr>
                                </table>
                            </form>
                        </div>
                    </center>
                    <% }%>
                </div>
                <div class="plan_body">

                </div>

            </div>
            <div class="container_right"><%@include file="/rightpannel.jsp" %></div>
        </div>
    </center>

</body>
</html>
